Repository navigation
Pin that a report's body goes out as UTF-8 with its length in bytes - #50
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
Author
|
Self-review rubric (scored against the diff and CI on head c1a01cd):
Repo-specific:
Finding, judgment only, not blocking: This review comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener). drafted by Claude on behalf of Daniel Stephenson |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stage B unit-test expansion: how a report's body is encoded on the wire is now pinned. Only tests are added, and no production code is changed.
Summary
report_sendsNonAsciiTextAsUtf8WithALengthCountedInBytes: an event whose name and tag hold a two-byte (é), a three-byte (€) and a four-byte (surrogate pair) character arrives as exactly the expected JSON in UTF-8. TheContent-Lengthheader equals the byte count, which is larger than the char count, andContent-Typeis exactlyapplication/json; charset=utf-8. Until now no test sent non-ASCII text over HTTP (onlyquote()was tested directly), and the existing Content-Type assertion checked only theapplication/jsonprefix.report_aLoneSurrogateIsSentAsAQuestionMarkRatherThanDroppingTheReport: half a surrogate pair in a tag value is passed through byquote()and replaced with?byString.getBytes(UTF_8). The report still goes out, with a matching length. This is recorded as current behaviour, not as a bug: the report is neither dropped nor turned into an exception.RawRequestfixture and areportAndCaptureRawRequesthelper capture the raw body bytes and the two headers on a loopback server of their own. The shared fixture decodes the body before storing it, so it cannot show the byte count.Regression evidence
send()streams the body withsetFixedLengthStreamingMode(bytes.length). As a check, that line was temporarily changed tobody.length()(chars instead of bytes). With that change the first new test failed (the report should reach the server ==> expected: <true> but was: <false>), because the connection rejected the body as longer than the declared length. With the line restored the test passed. The source change was reverted before committing, andgit statusshowed only the test file modified.Test plan
mvn -B verifylocally on Java 21:Tests run: 120, Failures: 0, Errors: 0, Skipped: 0, and both new tests appear in the surefire reportbuild (8),build (17),build (21)greenWork selection
Every open issue (#13, #15, #27, #31, #39, #40, #42) is deferred, as in the previous cycles: each asks for a maintainer decision on the opt-out contract, the wire format, or the "Opting out" README wording, which is on the do-not-auto-merge list. A read of
TraceClient.javaagainstTraceClientTest.javafound the server-wide parser, opt-outs, install ID, coalescing and JSON helpers already covered branch by branch. The body encoding on the wire was the remaining untested behaviour.Observation, not acted on: the README section "The wire format" does not say that the body is UTF-8. That could be added in a later documentation cycle. It is left out here so this PR stays test-only.
No tracking issue: this gap was found during triage.
This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).
🤖 Generated with Claude Code
drafted by Claude on behalf of Daniel Stephenson